<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  let obj = {
    name: "老陈",
    say:function (){
      console.log(arguments);
      console.log(this.name);
      console.log(this);
    }
  }
  let obj2 = {
    name: "老王"
  }
  // 实现apply
  Function.prototype.myApply = function (thisArg,arr) {
    if (thisArg === undefined || thisArg === null) {
      thisArg = window
    }
    // 定义一个不重复的常量作为属性
    const specialMethod = Symbol('anything')
    // 将不重复的属性给thisArg
    thisArg[specialMethod] = this
    // 调用函数并且返回结果
    let result = thisArg[specialMethod](...arr)
    // 删除新增的属性
    delete thisArg[specialMethod]
    return result
  }
  obj.say.myApply(obj2,[1,2,3])
</script>
</body>
</html>